package com.isoft.systemprovidor.controller;


import com.isoft.systemprovidor.bean.ResponseData;
import com.isoft.systemprovidor.bean.ResultCode;

public class BaseController {
    public ResponseData<Boolean> returnBoolean(Boolean result) {
        ResponseData<Boolean> responseData = new ResponseData<>() ;
        responseData.setData(result);
        if(result) {
            responseData.setErrorCode(ResultCode.SUCCESS.getCode());
            responseData.setMsg(String.valueOf(ResultCode.SUCCESS.getMessage()));
        } else {
            responseData.setErrorCode(ResultCode.COMMON_FAIL.getCode());
            responseData.setMsg(String.valueOf(ResultCode.COMMON_FAIL.getMessage()));
        }
        return responseData ;
    }
    public ResponseData<Object> returnObject(Object data) {
        ResponseData<Object> responseData = new ResponseData<>() ;
        responseData.setData(data);
        if(null != data) {
            responseData.setErrorCode(ResultCode.SUCCESS.getCode());
            responseData.setMsg(String.valueOf(ResultCode.SUCCESS.getMessage()));
        } else {
            responseData.setErrorCode(ResultCode.COMMON_FAIL.getCode());
            responseData.setMsg(String.valueOf(ResultCode.COMMON_FAIL.getMessage()));
        }
        return responseData ;
    }
}
